//package com.hyzh.latte.vehicle.repository;
//
//import cn.hutool.core.collection.CollectionUtil;
//import cn.hutool.core.util.StrUtil;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.hyzh.latte.vehicle.config.MinioConfig;
//import com.hyzh.latte.vehicle.dmo.VehicleTrackCameraVO;
//import com.hyzh.latte.vehicle.dmo.entity.VehicleInoutRecordPGEntity;
//import com.hyzh.latte.vehicle.repository.mapper.VehicleInoutRecordPGMapper;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//import java.time.LocalDateTime;
//import java.util.List;
//import java.util.Optional;
//import java.util.stream.Collectors;
//
//@Service
//@AllArgsConstructor
//@Slf4j
//public class VehicleInoutRecordPGRepository extends ServiceImpl<VehicleInoutRecordPGMapper, VehicleInoutRecordPGEntity> {
//
//    private final MinioConfig minioConfig;
//
//    public List<VehicleTrackCameraVO> enterpriseCamera(String cno, String vno, LocalDateTime startTime, LocalDateTime endTime) {
//        List<VehicleInoutRecordPGEntity> list =  this.lambdaQuery()
//                .select(VehicleInoutRecordPGEntity::getVehicleNo,
//                        VehicleInoutRecordPGEntity::getVehicleType,
//                        VehicleInoutRecordPGEntity::getCameraCode,
//                        VehicleInoutRecordPGEntity::getMinioObj,
//                        VehicleInoutRecordPGEntity::getEnterprises,
//                        VehicleInoutRecordPGEntity::getAddTime )
//                .likeRight(StrUtil.isNotEmpty(cno), VehicleInoutRecordPGEntity::getCameraCode, cno)
//                .likeRight(StrUtil.isNotEmpty(vno), VehicleInoutRecordPGEntity::getVehicleNo, cno)
//                .gt(null != startTime, VehicleInoutRecordPGEntity::getAddTime, startTime)
//                .lt(null != endTime,  VehicleInoutRecordPGEntity::getAddTime, endTime)
//                .orderByDesc(VehicleInoutRecordPGEntity::getAddTime)
//                .last("LIMIT 100")
//                .list();
//
//        if (CollectionUtil.isEmpty(list)){
//            log.info("vehicleNo: vno data is null, park: {}", "jiangan");
//            return null;
//        }
//
//        return list.stream().map(x -> {
//            VehicleTrackCameraVO vo = new VehicleTrackCameraVO();
//            vo.setVehicleNo(x.getVehicleNo());
//            vo.setCameraCode(x.getCameraCode());
//            vo.setVehicleType(x.getVehicleType());
//            vo.setAddTime(x.getAddTime());
//            vo.setImagePath(Optional.ofNullable(x.getMinioObj()).map(o -> minioConfig.getPath()+o).orElse(null));
//            vo.setEnterpriseName(x.getEnterprises());
//            return vo;
//        }).collect(Collectors.toList());
//    }
//
//}
